package Classes.GameViews.ViewPanels
{
	import Classes.GameViews.GV_Map;
	import Classes.GameViews.ViewIcons.VI_SingleLoadSwfIcon;
	import Classes.GameViews.ViewScenes.VS_Main;
	import Classes.Managers.M_LoadSWFSource;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;

	/** 
	 * 用来包装打开自己所需要的页面 
	 * @author thy
	 * @version 1.0.0 
	 * 创建时间：Mar 30, 2012 11:52:43 AM 
	 */ 
	public class VP_OpenWinView extends ViewPanel
	{
		private static var _instance:VP_OpenWinView;
		
		public function VP_OpenWinView(){}
		
		private var _callBack:Function;
		
		/**
		 * 打开需要打开的图片或者界面
		 */	
		public function openWindon(windownDis:DisplayObject,callFun:Function=null):void
		{
			this.addChild(windownDis);
			this._callBack=callFun;
			this.openAt(VS_Main.instance,true);
//			this.toCenter();
			this.scaleX		=	this.scaleY		=	1;
			this.x=(ZombieTown.instance.sysStage.stageWidth-this.width)/2;
			this.y=(ZombieTown.instance.sysStage.stageHeight-this.height)/2;
		}
		
		/**
		 * 打开去好友家的小loading条 
		 */		
		public function openGotoFriendPanel():void
		{
			var sp:Sprite=new Sprite();
//			sp.graphics.beginFill(0x666666);
			sp.graphics.drawRect(0,0,ZombieTown.instance.stage.stageWidth,ZombieTown.instance.stage.stageHeight);
//			sp.graphics.endFill();
			var dobj:DisplayObject=sp.addChild(new VI_SingleLoadSwfIcon("smallLoading","smallLoading_v",M_LoadSWFSource.instance.smallLoadingPath));
			dobj.x=ZombieTown.instance.stage.stageWidth/2;
			dobj.y=ZombieTown.instance.stage.stageHeight/2;
			this.openWindon(sp);
		}
		
		
		/**
		 *关闭界面  移除界面中的资源
		 * 
		 */		
		public function closeWin():void
		{
			this.graphics.clear();
			while(this.numChildren>0){this.removeChildAt(0);}
			this.close();
		}
		
		public static function get instance():VP_OpenWinView
		{
			if(!_instance)_instance=new VP_OpenWinView();
			return _instance;
		}
	}
}
